package com.gdut.simple.view.activity.user;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;

import com.gdut.simple.R;
import com.gdut.simple.contract.FeedbackContract;
import com.gdut.simple.data.entity.User;
import com.gdut.simple.presenter.user.FeedbackPresenter;
import com.gdut.simple.view.basic.AbsBasicActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.bmob.v3.BmobUser;

public class FeedbackActivity extends AbsBasicActivity implements FeedbackContract.View {

    @BindView(R.id.id_toolbar)
    Toolbar mToolbar;
    @BindView(R.id.id_feedback_content_text)
    EditText mFeedbackContentText;
    @BindView(R.id.id_feedback_contact_text)
    EditText mFeedbackContactText;

    @OnClick(R.id.id_commit_feedback_button)
    void commit() {
        mFeedbackPresenter.feedback();
    }

    private FeedbackContract.Presenter mFeedbackPresenter;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_feedback);
        ButterKnife.bind(this);
        new FeedbackPresenter(this);
        initToolbar();
    }

    private void initToolbar() {
        mToolbar.setTitle("意见反馈");
        setSupportActionBar(mToolbar);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    finish();
                }
            });
        }
    }

    @Override
    public User getUser() {
        return BmobUser.getCurrentUser(User.class);
    }

    @Override
    public String getContent() {
        return mFeedbackContentText.getText().toString();
    }

    @Override
    public String getContact() {
        return mFeedbackContactText.getText().toString();
    }

    @Override
    public void next() {
        finish();
    }

    @Override
    public void setPresenter(@NonNull FeedbackContract.Presenter presenter) {
        this.mFeedbackPresenter = presenter;
    }

}
